package com.hippy.struts.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hippy.struts.daoImpl.UserImpl;
import com.hippy.struts.entity.User;

public class LoginServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		PrintWriter out = resp.getWriter();
		String name = req.getParameter("userName");
		String pass = req.getParameter("userPass");
		System.out.println("login .......");
		System.out.println(name + "        " + pass);
		User u = new User();
		u.setNickName(name);
		u.setPass(pass);
		UserImpl ui = new UserImpl();
		boolean boo = ui.login(u);
		out.print(boo);
		out.flush();
		out.close();
	}

}
